package com.zzh.custom.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Display;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;

import androidx.annotation.NonNull;

import com.zzh.custom.R;


/**
 * @author zhangzhihao
 * @email zhangzhihao@gongjiangren.net
 * @date 2020-10-15
 * @desc 右部滑动出来的弹窗
 * */
public abstract class RightDialog extends Dialog {


    protected RightDialog(@NonNull Context context, int layoutId) {
        this(context, R.style.custom_level_select_dialog, layoutId);
    }

    protected RightDialog(@NonNull Context context, int themeResId, int layoutId) {
        super(context, themeResId);
        setContentView(layoutId);
        Window dialogWindow = getWindow();
        if (dialogWindow != null) {
            dialogWindow.setWindowAnimations(R.style.level_select_slide_anim);
            dialogWindow.setGravity(Gravity.RIGHT);
            WindowManager.LayoutParams p = dialogWindow.getAttributes();
            WindowManager m = dialogWindow.getWindowManager();
            Display d = m.getDefaultDisplay();
            p.height = (int) d.getHeight();
            p.width = (int) (d.getWidth() * 0.76);
            dialogWindow.setAttributes(p);
        }
    }

}